package com.example.wm.SanWar.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.wm.SanWar.entity.AlliesandUser;
import com.example.wm.SanWar.entity.NoteDetailEntity;
import com.example.wm.SanWar.entity.NoteEntity;
import com.example.wm.SanWar.service.AlliesandUserService;
import com.example.wm.SanWar.service.NoteDetailService;
import com.example.wm.common.Result;
import com.example.wm.common.ResultData;
import com.example.wm.utils.TsyUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/SanWarNoteDetailCotroller")
public class NoteDetailCotroller {
    @Resource
    private AlliesandUserService alliesandUserService;
    @Resource
    private NoteDetailService noteDetailService;
    @Resource
    private TsyUtils tsyUtils;
    @Transactional
    @PostMapping("/Insert")
    public Result Insert(@RequestBody NoteDetailEntity noteDetailEntity) {
        noteDetailService.save(noteDetailEntity);
        return ResultData.success("成功");
    }

    @Transactional
    @PostMapping("/findbyid")
    public Result findbyid(@RequestBody NoteDetailEntity noteDetailEntity) {
        LambdaQueryWrapper<NoteDetailEntity> lq=new LambdaQueryWrapper<>();
        lq.orderByAsc(NoteDetailEntity::getSequencenum);
        lq.ne(NoteDetailEntity::getCategory,  "评论");
        lq.eq(NoteDetailEntity::getNoteid,noteDetailEntity.getNoteid());

        List<NoteDetailEntity> list=  noteDetailService.list(lq);



     return ResultData.success(list);
    }
}
